﻿<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="../MasterPage.Master"
    CodeBehind="wfImportDataMnt.aspx.cs" Inherits="RH.wfImportDataMnt" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajax" %>
<%@ Import Namespace="Texfina.Common.Mg" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server">
    <link href="../Styles/jquery-ui.custom.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">
        window.onload = function () {
            var menuTable = document.getElementById('<%=mnuToolbar.ClientID %>');
            var menuLinks = menuTable.getElementsByTagName("a");
            if (menuLinks != null) {
                switch (menuLinks.length) {
                    case 2:
                        menuLinks[0].onclick = function () { return validateEditForm('_BTTSAVE') }
                        break;

                    case 3:
                        menuLinks[0].onclick = function () { return validateEditForm('_BTTSAVE') }
                        menuLinks[1].onclick = function () { return validateEditForm('_BTTSAVNEW') }
                        break;
                }
            }

            var mnuGrid = document.getElementById('<%=mnuGrid.ClientID %>');
            var mnuGridLinks = mnuGrid.getElementsByTagName("a");
            if (mnuGridLinks != null) {
                switch (mnuGridLinks.length) {
                    case 4:
                        mnuGridLinks[0].onclick = function () { return validateEditFormGrid('_BTTNEW') }
                        mnuGridLinks[1].onclick = function () { return validateEditFormGrid('_BTTIMPFIELD') }
                        mnuGridLinks[2].onclick = function () { return validateEditFormGrid('_BTTIMPDATA') }
                        mnuGridLinks[3].onclick = function () { return validateEditFormGrid('_BTTGENEDOC') }
                        mnuGridLinks[4].onclick = function () { return validateEditFormGrid('_BTTIMPVACA') }
                        break;
                }
            }
            this.ResizeGrid();
            this.MessageOnPostback();
        }

        function ResizeGrid() {
            internalGridResize("<%= tabMaster.ClientID %>");
        }

        function GetValueFile() {
            document.getElementById('<%=txtDocExcel.ClientID %>').value = document.getElementById('<%=fuDocExcel.ClientID %>').value;
        }

        function RadioCheck(rb) {
            var gv = document.getElementById("<%=grdList.ClientID%>");
            var rbs = gv.getElementsByTagName("input");
            var sel = gv.getElementsByTagName("select");
            var row = rb.parentNode.parentNode;

            for (var i = 0; i < rbs.length; i++) {
                if (rbs[i].type == "radio") {
                    if (rbs[i] == rb) {
                        sel[i].value = "";
                    }
                    if (rbs[i].checked && rbs[i] != rb) {
                        rbs[i].checked = false;
                    }
                }
            }
        }

        function SelectedCheckBoxAll(ckb) {
           var gv = document.getElementById("<%=grdListCampos.ClientID%>");
           var rbs = gv.getElementsByTagName("input");
           for (var i = 0; i < rbs.length; i++) {
              if (rbs[i].type == "checkbox") {
                 rbs[i].checked = ckb.checked;
              }
           }
        }
        
        function ddlidHoraValidate(objddl) {
            var gv = document.getElementById("<%=grdList.ClientID%>");
            var ddl = gv.getElementsByTagName("select");
            var rbs = gv.getElementsByTagName("input");
            var row = objddl.parentNode.parentNode;
            var flag = 0;
            for (var i = 0; i < ddl.length; i++) {
                if (ddl[i].type == "select-one") {
                    if (ddl[i].value == objddl.value && objddl.value != "") {
                        flag++;
                    }
                }
            }
            if (flag > 1) {
                objddl.value = "";
                alert("La Hora seleccionada es utilizada por otro campo.");

            }
            rbs[row.rowIndex - 1].checked = false;
        }

        function grdDropListExistsItem(value) {

           var gv = document.getElementById("<%=grdList.ClientID%>");
           var ddl = gv.getElementsByTagName("select");
           var rbs = gv.getElementsByTagName("input");
           var flag = 0;
           for (var i = 0; i < ddl.length; i++) {
              if (ddl[i].type == "select-one") {
                 if (ddl[i].value == value && value != "") {
                    flag++;
                 }
              }
           }
           if (flag > 0) {
              return true;
           }
           return false;
       }

       $(document).ready(function () {
           Sys.Application.add_load(end_page);
       });

       function end_page() {
           MessageOnPostback();
       }
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
    <div class="ToolBar">
        <asp:Menu ID="mnuToolbar" runat="server" CssClass="ToolBarControl" Orientation="Horizontal"
            OnMenuItemClick="mnuToolbar_MenuItemClick">
            <Items>
                <asp:MenuItem Text="Guardar" Value="_BTTSAVE" ImageUrl="../Images/Icons/Enabled/SAVE.png">
                </asp:MenuItem>
                <asp:MenuItem Text="Salir" Value="_BTTEXIT" ImageUrl="../Images/Icons/Enabled/BACK.png">
                </asp:MenuItem>
            </Items>
        </asp:Menu>
    </div>
    <div class="DataHeader">
        <table id="TableDataHeader" cellpadding="0" cellspacing="0">
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td style="width: 5px">
                    &nbsp;
                </td>
                <td>
                    <div style="border: 1px solid #ccc; border-radius: 5px; -moz-border-radius: 5px;
                        -webkit-border-radius: 5px; -ms-border-radius: 5px;">
                        <table width="100%" cellpadding="0" cellspacing="2">
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 10px;">
                                    &nbsp;
                                </td>
                                <td>
                                    Codigo Planilla
                                </td>
                                <td colspan="2">
                                    <esd:esdTextBox ID="txtidPlanilla" runat="server" Width="100px" />
                                </td>
                                <td colspan="30px">
                                    &nbsp;
                                </td>
                                <td>
                                    Planilla
                                </td>
                                <td colspan="2">
                                    <esd:esdTextBox ID="txtdsPlanilla" runat="server" Width="150px" />
                                </td>
                                <td colspan="30px">
                                    &nbsp;
                                </td>
                                <td>
                                    Forma de Pago
                                </td>
                                <td colspan="2">
                                    <esd:esdTextBox ID="txtdsFormaPago" runat="server" Width="150px" />
                                </td>
                                <td style="width: 10px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 10px;">
                                    &nbsp;
                                </td>
                                <td>
                                    Nro.Proceso Anual
                                </td>
                                <td colspan="10">
                                    <esd:esdNumericTextBox ID="txtNroProcAnual" NumericType="Integer" runat="server" Width="100px">
                                    </esd:esdNumericTextBox>
                                </td>
                                <td style="width: 10px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
                <td style="width: 5px">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
        </table>
    </div>
    <div class="DataDetail">
        <table width="100%" cellpadding="0" cellspacing="2">
            <tr>
                <td style="width: 5px">
                    &nbsp;
                </td>
                <td>
                    <ajax:TabContainer ID="tabMaster" ScrollBars="Auto" runat="server" 
                        ActiveTabIndex="0" CssClass="gray" Width="100%">
                        <ajax:TabPanel ID="tabChildConfig" runat="server" HeaderText="Configuracion">
                            <ContentTemplate>
                                <table width="100%" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td colspan="3">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px">
                                            &nbsp;
                                        </td>
                                        <td>
                                            <div style="border: 1px solid #ccc; border-radius: 5px; -moz-border-radius: 5px;
                                                -webkit-border-radius: 5px; -ms-border-radius: 5px;">
                                                <table width="100%" cellpadding="0" cellspacing="2">
                                                    <tr>
                                                        <td colspan="13">
                                                            &nbsp;
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td style="width: 5px;">
                                                            &nbsp;
                                                        </td>
                                                        <td style="width: 110px;">
                                                            Tipo de Migracion
                                                        </td>
                                                        <td style="width: 180px;">
                                                            <asp:DropDownList ID="ddlidTipoMigra" runat="server" Width="140px" ></asp:DropDownList>
                                                        </td>
                                                        <td style="width:80px;">
                                                            Formato Excel
                                                        </td>
                                                        <td style="width:200px;">
                                                            <esd:esdTextBox ID="txtDocExcel" runat="server" Width="200px"></esd:esdTextBox>
                                                        </td>
                                                        <td>
                                                            <div class="esdDivUploadFile">
                                                                <asp:FileUpload ID="fuDocExcel" onchange="GetValueFile();" runat="server" CssClass="esdUploadFile" Width="280px" accept="xls|xlsx" />
                                                                Examinar
                                                            </div>
                                                        </td>
                                                        <td colspan="6">
                                                            &nbsp;
                                                        </td>
                                                        <td style="width: 5px;">
                                                            &nbsp;
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td colspan="13">
                                                            &nbsp;
                                                        </td>
                                                    </tr>
                                                </table> 
                                             </div>
                                        </td> 
                                        <td style="width: 5px">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="3">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                            <div class="ToolBarGrid">
                                                <asp:Menu ID="mnuGrid" runat="server" Orientation="Horizontal" CssClass="ToolBarControl"
                                                    OnMenuItemClick="mnuGrid_MenuItemClick">
                                                    <Items>
                                                        <asp:MenuItem Text="  Nuevo Campo" Value="_BTTNEW" ImageUrl="../Images/Icons/Enabled/New.png">
                                                        </asp:MenuItem>
                                                        <asp:MenuItem Text="  Importar Campos" Value="_BTTIMPFIELD" ImageUrl="../Images/Icons/Enabled/ImportField.png">
                                                        </asp:MenuItem>
                                                        <asp:MenuItem Text="  Importar Datos" Value="_BTTIMPDATA" ImageUrl="../Images/Icons/Enabled/ImportTable.png">
                                                        </asp:MenuItem>
                                                        <asp:MenuItem Text="  Generar en blanco" Value="_BTTGENEDOC" ImageUrl="../Images/Icons/Enabled/GenerateTable.png">
                                                        </asp:MenuItem>
                                                        <asp:MenuItem Text="  Importar Horas de Vacaciones" Value="_BTTIMPVACA" ImageUrl="../Images/Icons/Enabled/CalendarCheck.png">
                                                        </asp:MenuItem>
                                                    </Items>
                                                </asp:Menu>
                                            </div>
                                            <esd:esdGridView CssClass="esdGridView" ID="grdList" runat="server" ScrollWidth="100%" ScrollHeight="300px" 
                                                Width="100%" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False" DataKeyNames="idHoraExcel"
                                                OnRowDataBound="grdList_RowDataBound" RowStyle-Height="22px">
                                                <Columns>
                                                    <asp:BoundField DataField="idHoraExcel" HeaderText="Posicion"></asp:BoundField>
                                                    <asp:BoundField DataField="dsHoraExcel" HeaderText="Campo Excel"></asp:BoundField>
                                                    <asp:BoundField DataField="idHora" HeaderStyle-CssClass="hideDataGridColumn" 
                                                    ItemStyle-CssClass="hideDataGridColumn">
                                                    </asp:BoundField>
                                                    <asp:TemplateField HeaderText="Codigo de Personal" ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                            <asp:RadioButton ID="rdbidPersonal" runat="server" onclick="RadioCheck(this);"/>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:TemplateField HeaderText="Hora" ItemStyle-HorizontalAlign="Center">
                                                        <ItemTemplate>
                                                            <asp:DropDownList ID="ddlidHora" runat="server" Width="250px" onChange="ddlidHoraValidate(this);">
                                                            </asp:DropDownList>
                                                        </ItemTemplate>
                                                    </asp:TemplateField>
                                                    <asp:BoundField DataField="stIdPersonal" HeaderStyle-CssClass="hideDataGridColumn" 
                                                    ItemStyle-CssClass="hideDataGridColumn">
                                                    </asp:BoundField>
                                                    <asp:BoundField DataField="stAnulado" HeaderStyle-CssClass="hideDataGridColumn" 
                                                    ItemStyle-CssClass="hideDataGridColumn">
                                                    </asp:BoundField>
                                                </Columns>
                                                <EmptyDataTemplate>
                                                    <div id="gridempty">
                                                        <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                                        &nbsp;No existen registros para esta solicitud.
                                                    </div>
                                                </EmptyDataTemplate>
                                            </esd:esdGridView>
                                        </td>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                </table>
                            </ContentTemplate>
                        </ajax:TabPanel>
                        <ajax:TabPanel ID="tabChildData" runat="server" HeaderText="Datos Importados/Generados">
                            <ContentTemplate>
                            <table width="100%" cellpadding="0" cellspacing="0">
                                    <tr>
                                        <td colspan="3">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                           <div style="border: 1px solid #ccc; border-radius: 5px; -moz-border-radius: 5px;
                                                   -webkit-border-radius: 5px; -ms-border-radius: 5px;">
                                                   <table width="100%" cellpadding="0" cellspacing="2">
                                                       <tr>
                                                           <td colspan="13">
                                                               <asp:Label ID="lblMessageLog" runat="server" ></asp:Label>
                                                           </td>
                                                       </tr>
                                                   </table>
                                           </div>
                                        </td>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                    </tr>
                                     <tr>
                                        <td colspan="3">
                                            &nbsp;
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                        <td>
                                            <esd:esdGridView CssClass="esdGridView" ID="grdListData" runat="server" ScrollWidth="100%" 
                                                ScrollHeight="500px" Width="100%" OnRowDataBound="grdListData_RowDataBound" 
                                                ShowHeaderWhenEmpty="True" AutoGenerateColumns="False" RowStyle-Height="22px" HeaderStyle-Font-Size="XX-Small">
                                                <EmptyDataTemplate>
                                                    <div id="gridempty">
                                                        <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                                        &nbsp;No existen registros para esta solicitud.
                                                    </div>
                                                </EmptyDataTemplate>
                                            </esd:esdGridView>
                                        </td>
                                        <td style="width: 5px;">
                                            &nbsp;
                                        </td>
                                    </tr>
                             </table>       
                            </ContentTemplate>
                        </ajax:TabPanel>
                    </ajax:TabContainer>
                 </td>
                 <td style="width: 5px">
                    &nbsp;
                 </td>
            </tr>
        </table>      
    </div>
    <asp:HiddenField ID="hdnMsgOPB" runat="server" />
    <asp:HiddenField ID="hdnidConRemu" runat="server" />
    <asp:HiddenField ID="hdnidConfig" runat="server" />

    <asp:Panel runat="server" ID="PnlPopup" CssClass="modalPopup" Width="380px" style=" display:none;">
        <table width="100%" cellpadding="0" cellspacing="2">
            <tr>
                <td colspan="3">
                    <div class="modalPopupHeader">
                        &nbsp;&nbsp;&nbsp;<asp:Label ID="lblTitlePopup" runat="server"></asp:Label>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="width: 5px;">
                    &nbsp;
                </td>
                <td>
                        <table width="100%" cellpadding="0" cellspacing="2">
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                                <td>
                                    Descripcion Campo
                                </td>
                                <td colspan="10">
                                    <esd:esdTextBox runat="server" ID="txtdsNewCampo" Width="200px"></esd:esdTextBox>
                                </td>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                </td>
                <td style="width: 5px;">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td style="width: 5px;">
                    &nbsp;
                </td>
                <td align="right">
                    <esd:esdButton ID="bttOkPopup" runat="server" Text="Aceptar" Width="80px" OnClick="bttOkPopup_Click">
                    </esd:esdButton>
                    <esd:esdButton ID="bttCancelPopup" runat="server" Text="Cancelar" Width="80px"></esd:esdButton>
                </td>
                <td style="width: 5px;">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
        </table>
    </asp:Panel>
    <ajax:ModalPopupExtender runat="server" ID="mdlPopup" PopupControlID="PnlPopup" BackgroundCssClass="modalBackground"
        TargetControlID="hdnidConRemu">
    </ajax:ModalPopupExtender>
    <asp:Panel runat="server" ID="PnlPopupConfi" CssClass="modalPopup" Width="450px" style=" display:none;">
        <table width="100%" cellpadding="0" cellspacing="2">
            <tr>
                <td colspan="3">
                    <div class="modalPopupHeader">
                        &nbsp;&nbsp;&nbsp;<asp:Label ID="lblTituloPopupConfi" runat="server"></asp:Label>
                    </div>
                </td>
            </tr>
            <tr>
                <td style="width: 5px;">
                    &nbsp;
                </td>
                <td>
                        <table width="100%" cellpadding="0" cellspacing="2">
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                                <td>
                                    Seleccione la Hoja Excel
                                </td>
                                <td colspan="10">
                                    <asp:DropDownList ID="ddlidHojaExcel" OnSelectedIndexChanged="ddlidHojaExcel_IndexChanged" AutoPostBack="true" runat="server" Width="240px">
                                    </asp:DropDownList>
                                </td>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                                <td colspan="11">
                                  <esd:esdGridView CssClass="esdGridView" ID="grdListCampos" runat="server" ScrollWidth="100%"
                                       Width="100%" ShowHeaderWhenEmpty="True" AutoGenerateColumns="False" OnRowDataBound="grdListCampos_RowDataBound"
                                       DataKeyNames="idHoraExcel"
                                       RowStyle-Height="22px">
                                       <Columns>
                                             <asp:TemplateField HeaderText="Sel.">
                                                <ItemTemplate>
                                                   <asp:CheckBox ID="chkSelected" runat="server" Checked="false" />
                                                </ItemTemplate>
                                                <HeaderStyle Width="22px" />
                                             </asp:TemplateField>
                                             <asp:BoundField DataField="idHoraExcel" HeaderText="Posicion"></asp:BoundField>
                                             <asp:BoundField DataField="dsHoraExcel" HeaderText="Campo Excel"></asp:BoundField>
                                             <asp:BoundField DataField="stAnulado" HeaderStyle-CssClass="hideDataGridColumn" 
                                             ItemStyle-CssClass="hideDataGridColumn">
                                             </asp:BoundField>
                                       </Columns>
                                       <EmptyDataTemplate>
                                             <div id="gridempty">
                                                <asp:Image ID="imgEmpty" runat="server" ImageUrl="../Images/Controls/Attention.png" />
                                                &nbsp;No existen registros para esta solicitud.
                                             </div>
                                       </EmptyDataTemplate>
                                    </esd:esdGridView>
                                </td>
                                <td style="width: 5px;">
                                    &nbsp;
                                </td>
                            </tr>
                            <tr>
                                <td colspan="13">
                                    &nbsp;
                                </td>
                            </tr>
                        </table>
                </td>
                <td style="width: 5px;">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td style="width: 5px;">
                    &nbsp;
                </td>
                <td align="right">
                    <esd:esdButton ID="bttOkPopupConfi" runat="server" Text="Aceptar" Width="80px" OnClick="bttOkPopupConfi_Click">
                    </esd:esdButton>
                    <esd:esdButton ID="bttCancelPopupConfi" runat="server" Text="Cancelar" Width="80px"></esd:esdButton>
                </td>
                <td style="width: 5px;">
                    &nbsp;
                </td>
            </tr>
            <tr>
                <td colspan="3">
                    &nbsp;
                </td>
            </tr>
        </table>
    </asp:Panel>
    <ajax:ModalPopupExtender runat="server" ID="mdlPopupConfi" PopupControlID="PnlPopupConfi" BackgroundCssClass="modalBackground"
        TargetControlID="hdnidConfig">
    </ajax:ModalPopupExtender>
</asp:Content>
